package com.sc.nft.service.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.StrUtil;
import com.sc.nft.dao.StaticDataDao;
import com.sc.nft.dao.UserCollectionDao;
import com.sc.nft.entity.ApplicationRequirement;
import com.sc.nft.entity.StaticData;
import com.sc.nft.entity.UserInfo;
import com.sc.nft.entity.vo.ApplicationRequirementFactoryVO;
import com.sc.nft.enums.ApplicationRequirementEnum;
import com.sc.nft.enums.DaoLevelTypeEnum;
import com.sc.nft.exception.GlobalRunTimeException;
import com.sc.nft.service.ApplicationRequirementFactoryService;
import com.sc.nft.util.DecideUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * 城主的要求实现
 */
@Slf4j
@RequiredArgsConstructor
@Service
public class CastellanApplicationRequirementFactoryServiceImpl implements ApplicationRequirementFactoryService {

    private final UserCollectionDao userCollectionDao;

    private final StaticDataDao staticDataDao;

    @Override
    public ApplicationRequirementFactoryVO applicationRequirement(UserInfo userInfo, ApplicationRequirement applicationRequirement,Integer type) {
//        if (BeanUtil.isEmpty(applicationRequirement)) {
//            throw new GlobalRunTimeException("城主申请条件参数不能为空");
//        }
//        StaticData cityLordCollectionId = staticDataDao.getByType("city_lord_collection_id");
////        Integer cityLordCount = userCollectionDao.applicationRequirement(userInfo.getId(), Convert.toLong(cityLordCollectionId.getValue()));
//        Integer cityLordCount =userInfo.getLevel()== DaoLevelTypeEnum.CITY_LORD?1:0;
//        ApplicationRequirementFactoryVO applicationRequirementFactoryVO = new ApplicationRequirementFactoryVO();
//        applicationRequirementFactoryVO.setKey(StrUtil.format("{}{}{}", applicationRequirement.getType().getDescription(), "", ""));
//        applicationRequirementFactoryVO.setAskForValue(applicationRequirement.getValue());
//        applicationRequirementFactoryVO.setPracticalValue(cityLordCount);
//        // 根据compoundMode字段中的 > < >= <= = 五中 来判定是否满足条件
//        applicationRequirementFactoryVO.setSatisfy(DecideUtil.conditionalDecision(cityLordCount, applicationRequirement.getValue(), applicationRequirement.getJudgingCriteria()));
//        return applicationRequirementFactoryVO;
        return null;
    }

    @Override
    public Integer code() {
        return ApplicationRequirementEnum.CASTELLAN.getCode();
    }

}
